package com.springboot.chongwu.controller.admin;


import com.springboot.chongwu.entity.Jibing;
import com.springboot.chongwu.entity.Zhixun;
import com.springboot.chongwu.qpage.QPage;
import com.springboot.chongwu.service.IJibingService;
import com.springboot.chongwu.service.IZhixunService;
import com.springboot.chongwu.util.ResultView;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotNull;

/**
 * <p>
 * 咨询表 前端控制器
 * </p>
 *
 * @author author
 * @since 2024-09-27
 */
@RestController
@RequestMapping("/api/admin/zhixun")
public class ZhixunController {


    @Autowired
    private IZhixunService service;


    /**
     * 列表分页
     * @param obj
     * @return
     */
    @GetMapping("/getPageList")
    public ResultView getPageList(QPage qPage, Zhixun obj) {
        return this.service.getPageList(qPage,obj);
    }


    /**
     * 根据ID获取当前数据
     * @return
     */
    @GetMapping("/getById")
    public ResultView getById(@NotNull(message = "ID不能为空") String id) {
        return ResultView.ok(this.service.getById(id));
    }

    /**
     * 新增
     * @param obj
     * @return
     */
    @PostMapping("/add")
    public ResultView add(@Validated Zhixun obj) {
        return this.service.add(obj);
    }

    /**
     * 删除
     * @return
     */
    @PostMapping("/del")
    public ResultView del(@NotNull(message = "ID不能为空") String id) {
        return this.service.del(id);
    }


    /**
     * 修改
     * @param obj
     * @return
     */
    @PostMapping("/up")
    public ResultView update(@Validated Zhixun obj) {
        return this.service.up(obj);
    }




}
